﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _27按键组合
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            //MyGrid.ColumnDefinitions.Add(new ColumnDefinition());
            //MyGrid.ColumnDefinitions.Add(new ColumnDefinition());

            Button button1 = new Button();
            button1.Name = "button1";
            button1.Content = "button1";
            //button1.Width = 100;
            //button1.Height = 100;
            MyGrid.Children.Add(button1);
            button1.SetValue(Grid.RowProperty, 0);
            button1.SetValue(Grid.ColumnProperty, 0);
            button1.Click += Button1_Click;

            //Button button2 = new Button();
            //button2.Name = "button2";
            //button2.Content = "button2";
            ////button2.Width = 100;
            ////button2.Height = 100;
            //MyGrid.Children.Add(button2);
            //button2.SetValue(Grid.RowProperty, 1);
            //button2.SetValue(Grid.ColumnProperty, 0);
            //button2.Click += Button2_Click;

            ucButton ucButton1 = new ucButton();
            ucButton1.button.Content = "测试按键";
            MyGrid.Children.Add(ucButton1);
            ucButton1.SetValue(Grid.RowProperty, 1);
            ucButton1.SetValue(Grid.ColumnProperty, 0);
            ucButton1.button.Click += Button_Click;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("click ucButton.button !");
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("click button2 !");
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("click button1 !");
        }
    }
}
